﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Enterprise.Framework.Frame.Architecture;
using Resto.CostControl.Core.Domain.Model;
using Enterprise.Framework.Core.Exceptions;
using Enterprise.Framework.DomainModel.Repositories;

namespace Resto.CostControl.Core.Domain.Query.SystemModule
{

    internal class DictionaryDQO : IDomainQueryObject
    {
        public Dictionary GetDictionary(string id)
        {
            Dictionary order = GetDictionaryOrDefault(id);

            if (order == null)
                throw new BusinessException("指定Id的供应商不存在");

            return order;
        }

        public Dictionary GetDictionaryOrDefault(string id)
        {
            IEntityRepository<Dictionary> repository = RestoCostDomainSession.CurrentSession.CreateEntityRepository<Dictionary>();
            Dictionary order = repository.Objects.Where(p => p.ID == id).FirstOrDefault();

            return order;
        }

        //public Dictionary[] GetDictionaryArrayByType(string typeCode)
        //{
        //    IEntityRepository<Dictionary> repository = RestoCostDomainSession.CurrentSession.CreateEntityRepository<Dictionary>();
        //    return repository.Objects.Where(p => p.TypeCode == typeCode).ToArray();

        //}

    }
 

}
